package com.kristin.fuctiontest;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class MainTest {

    public static void main(String[] args) {
        Consumer<Integer> consumer = number -> {
            System.out.println("print number : " + number);
        };

        consumer.accept(10);

        int[] ints = new int[]{1,4,5,6,76};
        Supplier<Integer> supplier = () -> {
            int sum = 0;
            for(int num : ints) {
                sum += num;
            }
            return sum;
        };
        System.out.println("supplier中的get值为:" + supplier.get());

        Predicate<Integer> predicate = (num) -> {
            return num > 100;
        };

        System.out.println(predicate.test(11));

        Function<String, Integer> function = number -> {
            return number.length();
        };
        System.out.println(function.apply("kristin"));
        System.out.println(function.andThen((num) -> {
            return num + 1;
        }).apply("kristin"));

    }


}
